package com.example.love_margin.Service.Impl.Until;


import org.springframework.stereotype.Component;

@Component
public class delPetsUtil {

    public String admin(String pictureURL,String SqlName,String Key,Integer[] someID){
        StringBuilder URL = new StringBuilder();
        URL.append("SELECT ").append(pictureURL).append(" FROM ").append(SqlName).append(" WHERE ").append(Key).append(" IN ");
        URL.append("(");

        for (int i = 0; i < someID.length; i++) {
            URL.append(someID[i]);
            if (i < someID.length - 1) {
                URL.append(",");
            }
        }
        URL.append(")");
        return URL.toString();
    }

    public String deleSQL (String SqlName,String Key,Integer[] someID){
        StringBuilder URL = new StringBuilder();
        URL.append("DELETE FROM ").append(SqlName).append(" WHERE ").append(Key).append(" IN ");
        URL.append("(");
        for (int i = 0; i < someID.length; i++) {
            URL.append(someID[i]);
            if (i < someID.length - 1) {
                URL.append(",");
            }
        }
        URL.append(")");
        return URL.toString();
    }

    public String upOneSQL (String SqlName,String Key,String KeyValue,String ID,Integer[] someID){
        StringBuilder URL = new StringBuilder();
        URL.append("UPDATE ").append(SqlName).append(" SET ").append(Key).append(" = ").append(KeyValue).append(" WHERE ").append(ID).append(" IN ");
        URL.append("(");

        for (int i = 0; i < someID.length; i++) {
            URL.append(someID[i]);
            if (i < someID.length - 1) {
                URL.append(",");
            }
        }
        URL.append(")");
        return URL.toString();
    }

}
